import React, { Component } from 'react';
import styles from './index.less';

export default class extends Component {
  sendMsg = () => {
    var data = {
      type: 'test',
      data: {
        name: '测试数据',
      },
    };
    window.opener.postMessage(JSON.stringify(data), 'http://localhost:8000');
    window.close();
  };

  render() {
    return (
      <div
        onClick={() => {
          this.sendMsg();
        }}
      >
        向之前页面发送数据
      </div>
    );
  }
}
